#include "../include/dir.h"

int handle_mkdir(path_t *path, const char *dirName, char *buf, int buf_len){
    //清空buf 避免调用了多次带buf的函数后面会输出前面buf内容 测试问题mkdir->ls
    bzero(buf, buf_len);
    
    //将目录名当相对路径处理
    char newVirPath[MAX_PATH_LEN] = {0};
    char newRealPath[MAX_PATH_LEN] = {0};

    makePath(path, dirName, newVirPath, newRealPath);

    if(mkdir(newRealPath, 0755)){
        sprintf(buf, "创建失败: %s\n", strerror(errno));
        return -1;
    }
    sprintf(buf, "目录%s 创建成功.\n", dirName);
    return 0;
}
